<!DOCTYPE html>
<html lang="en">


{include file="Public/head"}

<body data-type="widgets">
<script src="/assets/js/theme.js"></script>
<div class="am-g tpl-g">

	{include file='Public:header'}
	{include file='Public:menu2'}



	<!-- 内容区域 -->
	<div class="tpl-content-wrapper">
		<div class="row-content am-cf">
			<div class="row">
				<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
					<div class="widget am-cf">
						<div class="widget-head am-cf">
							<div class="widget-title  am-cf">广告列表</div>
						</div>
						<div class="widget-body  am-fr">



                                <!--<nav class="navbar navbar-default">-->
							<!--<div class="form-group pull-right-center">-->
								<!--<a href="{:url('admin/Ad/positionadd')}" style="padding: 13px 13px" class="btn btn-primary pull-right" ><i class="fa fa-plus"></i> 新增广告位置</a>-->
							<!--</div>-->
                                <!--</nav>-->


                            <div class="widget-body  am-fr">





                            <div class="am-u-sm-12">
								<table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black " id="example-r">
									<thead>
									<tr>
										<th>广告位id</th>
										<th>广告位名称</th>
										<th>广告位宽度</th>
										<th>广告位高度</th>
										<th>广告位描述</th>
										<th>状态</th>
										<th>操作</th>
									</tr>
									</thead>
									<tbody>
									{volist name='res' id='vo'}
									<tr class="gradeX">
										<td>{$vo.position_id}</td>
										<td>{$vo.position_name}</td>
										<td>{$vo.ad_width}</td>
										<td>{$vo.ad_height}</td>
										<td>{$vo.position_desc}</td>
                                        <td>
                                            {if condition='$vo.is_open eq 1'}
                                            <img width="20" height="20" src="/assets/img/yes.png" onclick="statechange(this)" stateid="{$vo.position_id}" />
                                            {else}
                                            <img width="20" height="20" src="/assets/img/cancel.png"   onclick="statechange(this)" stateid="{$vo.position_id}"/>
                                            {/if}
                                        </td>

										<td>
											<div class="tpl-table-black-operation">
												<a href="{:Url('position_edit')}?position_id={$vo.position_id}">
													<i class="am-icon-pencil"></i> 编辑
												</a>
												<a  href="{:Url('adList')}?pid={$vo.position_id}"  style="display: inline-block;color: black;border: black 1px solid;padding: 5px 6px;font-size: 12px;line-height: 12px;">
													<i class="am-icon-copy"></i> 查看广告
												</a>
												
											</div>
										</td>
									</tr>
									{/volist}
									<!-- more data -->
									</tbody>
								</table>
							</div>
							<div class="am-u-lg-10 am-cf">

								<div class="am-fr">
									<ul class="am-pagination tpl-pagination">
									{$res->render()}
									</ul>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
</div>

</body>
{include file='Public:script'}
<script>

    //状态改变
    function statechange(e) {
        if($(e).attr('src').indexOf("cancel.png") > 0 )
        {
            src = '/assets/img/yes.png';
            var value = 1;
        }else{
            src = '/assets/img/cancel.png';
            var value = 0;
        }
        var position_id = $(e).attr('stateid');

        $.ajax({
            url:'statechange', /*去过那个php文件*/
            type:'POST',  /*提交方式*/
            data:{
                'position_id':position_id,
				'is_open':value
			},
            cache: false,
            dataType: "json",
            success:function(xhr){
                $(e).attr('src',src);
            }
        })
    }



</script>
</html>